
//注册输入框校验
$(function(){
    $(".register-body input[name=phone]").focus(function(){
        $(".register-body p[name=msg1]").css("color","#ccc").html("手机号码将作为您的登录账号");
    });
    $(".register-body input[name=phone]").blur(function(){
        //手机号
        var phone= $(".register-body input[name=phone]").val();
        var row1 = isPhone(phone);
        if(row1.pass==false){
            $(".register-body p[name=msg1]").css("color","#eb6100").html(row1.msg);
            return;
        }

    });
    $(".register-body input[name=smsVerificationCode]").focus(function(){
        $(".register-body p[name=msg2]").html("");
    });
    $(".register-body input[name=smsVerificationCode]").blur(function(){
        //验证码
        var phoneCode=$(".register-body input[name=smsVerificationCode]").val();
        if(!phoneCode){
            $(".register-body p[name=msg2]").html("请输入验证码");
            return;
        }
    });
    $(".register-body input[name=passWd]").focus(function(){
        $(".register-body p[name=msg3]").css("color","#ccc").html("8~32个字符的密码");
    });
    $(".register-body input[name=passWd]").blur(function(){
        //密码
        var password1=$(".register-body input[name=passWd]").val();
        //var password2=$("input[name=password2]").val();
        if(!password1){
            $(".register-body p[name=msg3]").css("color","#eb6100").html("请输入8~32个字符的密码");
            return;
        }if(password1.length<8 || password1.length>32){
            $(".register-body p[name=msg3]").css("color","#eb6100").html("请输入8~32个字符的密码")
            return;
        }
    });
    $(".register-body input[name=passWord]").focus(function(){
        $(".register-body p[name=msg4]").html("");
    });
    $(".register-body input[name=passWord]").blur(function(){
        //二次密码
        var password1=$(".register-body input[name=passWd]").val();
        var password2=$(".register-body input[name=passWord]").val();

        if(!password2){
            $(".register-body p[name=msg4]").html("请再次输入密码");
            return;
        }if(password1!=password2){
            $(".register-body p[name=msg4]").html("两次密码不一致");
            return;
        }

    });

    // ajax
});
//登录输入框校验
// $(function(){
//     $(".lg-body #longinBtn").click(function(){
//         var phone=$(".lg-body input[name=phone]").val();
//         if(!phone){
//             $(".lg-body p[name=msg]").html("请输入用户名！")
//             return;
//         }
//         var password=$(".lg-body input[name=password]").val;
//         if(!password){
//             $(".lg-body p[name=msg]").html("请输入密码！")
//             return;
//         }
//         // ajax
//     });
// });
//实名认证
$(function(){
    $(".rename-body input[name=userName]").focus(function(){
        $(".rename-body p[name=msg1]").html("")
    });
    $(".rename-body input[name=userName]").blur(function(){
        var userName=$(".rename-body input[name=userName]").val();
        var row = isChinese(userName);
        if(row.pass==false){
            $(".rename-body p[name=msg1]").html(row.msg);
            return;
        }

    });
    $(".rename-body input[name=idCard]").focus(function(){
        $(".rename-body p[name=msg2]").html("")
    });
    $(".rename-body input[name=idCard]").blur(function(){
        var idCard=$(".rename-body input[name=idCard]").val();
        var row = isIdCodeValid(idCard);
        if(row.pass==false){
            $(".rename-body p[name=msg2]").html(row.msg);
            return;
        }
    })
    // ajax
});
//交易密码
$(function(){
    $(".newpaypd-body input[name=newPaymentPassword]").focus(function(){
        $(".newpaypd-body p[name=msg1]").html("")
    });
    $(".newpaypd-body input[name=newPaymentPassword]").blur(function(){
        var newPay=$(".newpaypd-body input[name=newPaymentPassword]").val();
        var row = isPositiveInteger(newPay);
        if(row.pass==false){
            $(".newpaypd-body p[name=msg1]").html(row.msg);
            return;
        }if(newPay.length!=6){
            $(".newpaypd-body p[name=msg1]").html("请输入6位密码");
            return;
        }

    });
    $(".newpaypd-body input[name=new-PaymentPassword]").focus(function(){
        $(".newpaypd-body p[name=msg2]").html("")
    });
    $(".newpaypd-body input[name=new-PaymentPassword]").blur(function(){
        var cpNewPay=$(".newpaypd-body input[name=new-PaymentPassword]").val();
        var newPay=$(".newpaypd-body input[name=newPaymentPassword]").val();
        if(cpNewPay!=newPay){
            $(".newpaypd-body p[name=msg2]").html("两次密码不一致");
            return;
        }
    })
    // ajax
});
//绑卡
$(function(){
   $(".bindingbankcard-body input[name=bankCardNumber]").focus(function(){
       $(".bindingbankcard-body p[name=msg1]").html("");
   });
   $(".bindingbankcard-body input[name=bankCardNumber]").blur(function(){
       var bankCardNumber=$(".bindingbankcard-body input[name=bankCardNumber]").val();
       var bank=bankCardAttribution(bankCardNumber)
       if(!bankCardNumber){
           $(".bindingbankcard-body p[name=msg1]").html("请输入银行卡号");
           return;
       }if(bank=="error"){
           $(".bindingbankcard-body input[name=bankName]").val("")
           $(".bindingbankcard-body p[name=msg1]").html("请输入正确银行卡号");
           return;
       }else{
           $(".bindingbankcard-body input[name=bankName]").val(bank.bankName);
       }
   });
   // $(".bindingbankcard-body input[name=bankName]").focus(function(){
   //      $(".bindingbankcard-body p[name=msg2]").html("");
   // });
   // $(".bindingbankcard-body input[name=bankName]").blur(function(){
   //      var bankName=$(".bindingbankcard-body input[name=bankName]").val();
   //      if(!bankName){
   //          $(".bindingbankcard-body p[name=msg2]").html("请输入银行卡归属");
   //      }
   // });
   $(".bindingbankcard-body input[name=cardholderName]").focus(function(){
       $(".bindingbankcard-body p[name=msg3]").html("");
   });
   $(".bindingbankcard-body input[name=cardholderName]").blur(function(){
       var cardholderName=$(".bindingbankcard-body input[name=cardholderName]").val();
       if(isChinese(cardholderName).pass==false){
           $(".bindingbankcard-body p[name=msg3]").html("请输入中文姓名");
           return;
       }if(cardholderName.length<2 || cardholderName.length>20){
           $(".bindingbankcard-body p[name=msg3]").html("请输入正确中文姓名");
           return;
       }
   });
   $(".bindingbankcard-body input[name=idCard]").focus(function(){
       $(".bindingbankcard-body p[name=msg4]").html("");
   });
   $(".bindingbankcard-body input[name=idCard]").blur(function(){
       var idCard=$(".bindingbankcard-body input[name=idCard]").val();
       var row = isIdCodeValid(idCard);
       if(row.pass==false){
           $(".bindingbankcard-body p[name=msg4]").html(row.msg);
           return;
       }
   });
   $(".bindingbankcard-body input[name=paymentPassword]").focus(function(){
       $(".bindingbankcard-body p[name=msg5]").html("");
   });
   $(".bindingbankcard-body input[name=paymentPassword]").blur(function(){
       var paymentPassword=$(".bindingbankcard-body input[name=paymentPassword]").val();
       if(isPositiveInteger(paymentPassword).pass==false){
           $(".bindingbankcard-body p[name=msg5]").html("请输入数字支付密码");
           return;
       }if(paymentPassword.length!=6){
           $(".bindingbankcard-body p[name=msg5]").html("请输入6位支付密码");
           return;
       }
   });
});
//充值
$(function(){
    $(".recharge-body input[name=bankCardNumber]").focus(function(){
        $(".recharge-body p[name=msg1]").html("");
    });
    $(".recharge-body input[name=bankCardNumber]").blur(function(){
        var idCard=$(".recharge-body input[name=bankCardNumber]").val();
        if(!idCard){
            $(".recharge-body p[name=msg1]").html("请输入银行卡号");
            return;
        }
        var bank=bankCardAttribution(idCard);
        if(bank=="error"){
            $(".recharge-body p[name=msg1]").html("请输入正确银行卡号");
            return;
        }
    });
    $(".recharge-body input[name=paymentPassword]").focus(function(){
        $(".recharge-body p[name=msg2]").html("");
    });
    $(".recharge-body input[name=paymentPassword]").blur(function(){
        var paymentPassword=$(".recharge-body input[name=paymentPassword]").val();
        if(isPositiveInteger(paymentPassword).pass==false){
            $(".recharge-body p[name=msg2]").html("请输入数字支付密码");
            return;
        }if(paymentPassword.length!=6){
            $(".recharge-body p[name=msg2]").html("请输入6位支付密码");
            return;
        }
    })
    $(".recharge-body input[name=number]").focus(function(){
        $(".recharge-body p[name=msg3]").html("");
    });
    $(".recharge-body input[name=number]").blur(function(){
        var number=$(".recharge-body input[name=number]").val();
        if(isPositiveNumber(number).pass==false){
            $(".recharge-body p[name=msg3]").html("请输入正确充值金额");
            return;
        }
    })
});
//提现
$(function(){
    $(".consumption-body input[name=bankCardNumber]").focus(function(){
        $(".consumption-body p[name=msg1]").html("");
    });
    $(".consumption-body input[name=bankCardNumber]").blur(function(){
        var idCard=$(".consumption-body input[name=bankCardNumber]").val();
        if(!idCard){
            $(".consumption-body p[name=msg1]").html("请输入银行卡号");
            return;
        }
        var bank=bankCardAttribution(idCard);
        if(bank=="error"){
            $(".consumption-body p[name=msg1]").html("请输入正确银行卡号");
            return;
        }
    });

    $(".consumption-body input[name=balance]").focus(function(){
        $(".consumption-body p[name=msg2]").html("");
    });
    $(".consumption-body input[name=balance]").blur(function(){
        var number=$(".consumption-body input[name=balance]").val();
        if(isPositiveNumber(number).pass==false){
            $(".consumption-body p[name=msg2]").html("请输入正确充值金额");
            return;
        }
    })
    $(".consumption-body input[name=paymentPassword]").focus(function(){
        $(".consumption-body p[name=msg3]").html("");
    });
    $(".consumption-body input[name=paymentPassword]").blur(function(){
        var paymentPassword=$(".consumption-body input[name=paymentPassword]").val();
        if(isPositiveInteger(paymentPassword).pass==false){
            $(".consumption-body p[name=msg3]").html("请输入数字支付密码");
            return;
        }if(paymentPassword.length!=6){
            $(".consumption-body p[name=msg3]").html("请输入6位支付密码");
            return;
        }
    })
});
//解绑卡
$(function(){
    $(".ubcard-body input[name=bankCardNumber]").focus(function(){
        $(".ubcard-body p[name=msg1]").html("");
    });
    $(".ubcard-body input[name=bankCardNumber]").blur(function(){
        var bankCardNumber=$(".ubcard-body input[name=bankCardNumber]").val();
        var bank=bankCardAttribution(bankCardNumber)
        if(!bankCardNumber){
            $(".ubcard-body p[name=msg1]").html("请输入银行卡号");
            return;
        }if(bank=="error"){
            //$(".ubcard-body input[name=bankCardNumber]").val("")
            $(".ubcard-body p[name=msg1]").html("请输入正确银行卡号");
            return;
        }
    });
    $(".ubcard-body input[name=paymentPassword]").focus(function(){
        $(".ubcard-body p[name=msg2]").html("");
    });
    $(".ubcard-body input[name=paymentPassword]").blur(function(){
        var paymentPassword=$(".ubcard-body input[name=paymentPassword]").val();
        if(isPositiveInteger(paymentPassword).pass==false){
            $(".ubcard-body p[name=msg2]").html("请输入数字支付密码");
            return;
        }if(paymentPassword.length!=6){
            $(".ubcard-body p[name=msg2]").html("请输入6位支付密码");
            return;
        }
    });
});
//修改支付密码
$(function(){
    $(".chpwd-body input[name=originalPasswd]").focus(function(){
        $(".chpwd-body p[name=msg1]").html("");
    });
    $(".chpwd-body input[name=originalPasswd]").blur(function(){
        var originalPasswd=$(".chpwd-body input[name=originalPasswd]").val();
        if(isPositiveInteger(originalPasswd).pass==false){
            $(".chpwd-body p[name=msg1]").html("请输入数字支付密码");
            return;
        }if(originalPasswd.length!=6){
            $(".chpwd-body p[name=msg1]").html("请输入6位支付密码");
            return;
        }
    });
    $(".chpwd-body input[name=newPasswd]").focus(function(){
        $(".chpwd-body p[name=msg2]").html("");
    });
    $(".chpwd-body input[name=newPasswd]").blur(function(){
        var newPasswd=$(".chpwd-body input[name=newPasswd]").val();
        if(isPositiveInteger(newPasswd).pass==false){
            $(".chpwd-body p[name=msg2]").html("请输入数字支付密码");
            return;
        }if(newPasswd.length!=6){
            $(".chpwd-body p[name=msg2]").html("请输入6位支付密码");
            return;
        }
    })
    $(".chpwd-body input[name=repeatPasswd]").focus(function(){
        $(".chpwd-body p[name=msg3]").html("");
    });
    $(".chpwd-body input[name=repeatPasswd]").blur(function(){
        var newPasswd=$(".chpwd-body input[name=newPasswd]").val();
        var repeatPasswd=$(".chpwd-body input[name=repeatPasswd]").val();
        if(!repeatPasswd){
            $(".chpwd-body p[name=msg3]").html("请再次输入密码");
        }if(newPasswd != repeatPasswd){
            $(".chpwd-body p[name=msg3]").html("两次密码不一致");
        }
    })
});
//修改登录密码
$(function(){
    $(".chpwdLogin-body input[name=originalPasswd]").focus(function(){
        $(".chpwdLogin-body p[name=msg1]").html("");
    });
    $(".chpwdLogin-body input[name=originalPasswd]").blur(function(){
        var originalPasswd=$(".chpwdLogin-body input[name=originalPasswd]").val();
        if(isPositiveInteger(originalPasswd).pass==false){
            $(".chpwdLogin-body p[name=msg1]").html("请输入登录密码");
            return;
        }if(originalPasswd.length<6 || originalPasswd.length>32){
            $(".chpwdLogin-body p[name=msg1]").html("请输入登录密码，限6-32位");
            return;
        }
    });
    $(".chpwdLogin-body input[name=newPasswd]").focus(function(){
        $(".chpwdLogin-body p[name=msg2]").html("");
    });
    $(".chpwdLogin-body input[name=newPasswd]").blur(function(){
        var newPasswd=$(".chpwdLogin-body input[name=newPasswd]").val();
        if(isPositiveInteger(newPasswd).pass==false){
            $(".chpwdLogin-body p[name=msg2]").html("请输入登录密码");
            return;
        }if(newPasswd.length<6 || newPasswd.length>32){
            $(".chpwdLogin-body p[name=msg2]").html("请输入登录密码，限6-32位");
            return;
        }
    })
    $(".chpwdLogin-body input[name=repeatPasswd]").focus(function(){
        $(".chpwdLogin-body p[name=msg3]").html("");
    });
    $(".chpwdLogin-body input[name=repeatPasswd]").blur(function(){
        var newPasswd=$(".chpwdLogin-body input[name=newPasswd]").val();
        var repeatPasswd=$(".chpwdLogin-body input[name=repeatPasswd]").val();
        if(!repeatPasswd){
            $(".chpwdLogin-body p[name=msg3]").html("请再次输入密码");
        }if(newPasswd != repeatPasswd){
            $(".chpwdLogin-body p[name=msg3]").html("两次密码不一致");
        }
    })
});
//发布项目
$(function(){
    //项目名称
    $(".proRelease-body input[name=projectName]").focus(function(){
        $(".proRelease-body p[name=msg1]").html("");
    });
    $(".proRelease-body input[name=projectName]").blur(function(){
        var projectName=$(".proRelease-body input[name=projectName]").val();
        if(!projectName){
            $(".proRelease-body p[name=msg1]").html("请输入项目名称");
        };
    });
    //项目金额
    $(".proRelease-body input[name=totalProject]").focus(function(){
        $(".proRelease-body p[name=msg2]").html("");
    });
    $(".proRelease-body input[name=totalProject]").blur(function(){
        var totalProject=$(".proRelease-body input[name=totalProject]").val();
        if(!totalProject){
            $(".proRelease-body p[name=msg2]").html("请输入项目金额");
        }if(isPositiveNumber(totalProject).pass==false || totalProject=="0"){
            $(".proRelease-body p[name=msg2]").html("请输入正确项目金额");
        }
    });
    //项目期限
    $(".proRelease-body input[name=projectDeadline]").focus(function(){
        $(".proRelease-body p[name=msg3]").html("");
    });
    $(".proRelease-body input[name=projectDeadline]").blur(function(){
        var projectDeadline=$(".proRelease-body input[name=projectDeadline]").val();
        if(!projectDeadline){
            $(".proRelease-body p[name=msg3]").html("请输入项目期限");
        }if(isPositiveInteger(projectDeadline).pass==false || projectDeadline=="0" ){
            $(".proRelease-body p[name=msg3]").html("请输入正确项目期限");
        }
    });
    //年利率
    $(".proRelease-body input[name=annualInterestRate]").focus(function(){
        $(".proRelease-body p[name=msg4]").html("");
    });
    $(".proRelease-body input[name=annualInterestRate]").blur(function(){
        var annualInterestRate=$(".proRelease-body input[name=annualInterestRate]").val();
        if(!annualInterestRate){
            $(".proRelease-body p[name=msg4]").html("请输入年利率");
        }if(isPositiveNumber(annualInterestRate).pass==false){
            $(".proRelease-body p[name=msg4]").html("请输入正确年利率");
        }
    });
    //额外利率
    $(".proRelease-body input[name=extraInterestRate]").focus(function(){
        $(".proRelease-body p[name=msg5]").html("");
    });
    $(".proRelease-body input[name=extraInterestRate]").blur(function(){
        var extraInterestRate=$(".proRelease-body input[name=extraInterestRate]").val();
        if(!extraInterestRate){
            $(".proRelease-body p[name=msg5]").html("请输入额外利率");
        }if(isPositiveNumber(extraInterestRate).pass==false){
            $(".proRelease-body p[name=msg5]").html("请输入正确额外利率");
        }
    });
    //发布时间
    $(".proRelease-body input[name=releaseTime]").focus(function(){
        $(".proRelease-body p[name=msg6]").html("");
    });
    $(".proRelease-body input[name=releaseTime]").blur(function(){
        var releaseTime=$(".proRelease-body input[name=releaseTime]").val();
        if(!releaseTime){
            $(".proRelease-body p[name=msg6]").html("请选择发布时间");
        };
    });
});
// $(function () {
//     $("input").blur(function(){
//         var bankCard=$("input").val();
//         var bank=bankCardAttribution(bankCard)
//         $("p").html(bank)
//         console.log(bank.bankName)
//         console.log(bank)
//     })
// })